@extends('layouts.console_header')

@section('title', '新增/修改个人地推方案')

@section('resources')
    @parent
	<style>
		.user_list{border: none;}
		#user_setup .setup_outer{font-size: 14px;padding: 0 15px;}
		#user_setup .setup_outer .setup_outerli{border-bottom: 1px solid #eee;overflow: hidden;}
		#user_setup .setup_outer .setup_outerli .front{width: 115px;float: left;margin-right: 15px;margin-top: 20px;}
		#user_setup .setup_outer .setup_outerli ul{float: left;width: 1000px;}
		#user_setup .setup_outer .setup_outerli ul li{margin: 20px 0;}
		#user_setup .setup_outer .setup_outerli ul input[type='text']{width: 50px;height: 20px;border: 1px solid #000;border-radius: 5px;text-align: center;}
		#user_setup .button{margin: 20px 140px;overflow: hidden;}
		#user_setup .button input[type='button']{float: left;width: 100px;height: 30px;font-size: 18px;margin: 0 20px;border-radius: 5px;cursor: pointer;}
		#user_setup .button .user_setup_preserve{background-color: #9955c6;color: #fff;}
		#user_setup .button .user_setup_cancel{background-color: #fff;color: #808080;border: 1px solid #808080;}
		.setup_name_input{width: 600px;height: 20px;padding: 5px;float: left;border: 1px solid #666;margin: 10px 0;}
	</style>
@endsection

@section('content')
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
        <p class="fz_14 account_title fl" style="border: none;">
            <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>地推管理><a href="/console/salesman/setup">地推设置</a>></span>
            <span class="co_violet">新增个人地推方案</span>
        </p>
        <a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
    </div>
	<!-- 个人地推 -->
	<!-- 新增 -->
	@if($edittype == 'add')
        <form action="" method="" id="user_setup">
        <ul class="setup_outer">
            <input type="hidden" name="cityid" value="{{$cityid}}" />
            <input type="hidden" name="salesmantype" value="usersalesman">
            <input type="hidden" name="shoptype" value="">
            <input type="hidden" name="edittype" value="{{$edittype}}">
            <input type="hidden" name="salesmansetid" value="">
            <li hidden class="setup_outerli">
                <span class="front">结算周期：</span>
                <ul>
                    <li>
                        <input type="radio" name="" value="" checked>
                        <span>每</span>
                        <input type="text" name="accountperiod" value="1">
                        <span>个月结算</span>
                    </li>
                </ul>
            </li>
            <li class="setup_outerli">
                <span class="front">地推名称：</span>
                <input class="setup_name_input" type="text" name="name" value="" placeholder="限20字，请输入地推方案名称" maxlength="20">
            </li>
            <li class="setup_outerli">
                <span class="front">结算周期：</span>
                <input class="setup_name_input" type="text" name="accountperioddescription" value="" placeholder="请输入结算周期说明">
            </li>
            <li class="setup_outerli">
                <span class="front">有效地推定义：</span>
                <ul>
                    <li>
                        <input type="radio" name="validsalesmanruletype" value="1" checked>
                        <span>同城新用户下载翻贝网App，首次登录时扫描地推二维码，获取邀请码完成登录即可。首次登录时未获取邀请码，可在2小时内用扫一扫功能扫地推二维码即可。</span>
                    </li>
                    <li hidden>
                        <input type="radio" name="validsalesmanruletype" value="2">
                        <span>新用户登录app且消费</span>
                        <input type="text" name="validorderminnum" value="0">
                        <span>笔，单笔消费金额需达</span>
                        <input type="text" name="validorderminamount" value="0">
                        <span>以上</span>
                    </li>
                </ul>
            </li>
            <li class="setup_outerli">
                <span class="front">个人地推结算：</span>
                <ul>
                    <li>
                        <input type="radio" name="accounttype" value="1" checked>
                        <span>每个有效地推的注册用户</span>
                        <input type="text" name="registergetmoney1" value="0">
                        <span>元</span>
                    </li>
                    <li>
                        <input type="radio" name="accounttype" value="2">
                        <span>每个有效地推的注册用户</span>
                        <input type="text" name="registergetmoney2" value="0">
                        <span>元，且该用户的每笔消费实付金额满</span>
                        <input type="text" name="accountorderminamount" value="0">
                        <span>以上的订单按</span>
                        <input type="text" name="ordergetmoney" value="0">
                        <span>元／单计为地推订单收入</span>
                    </li>
                    <li>
                        <input type="radio" name="accounttype" value="3">
                        <span>每个有效地推的注册用户</span>
                        <input type="text" name="registergetmoney3" value="0">
                        <span>元，且该用户的每笔消费按实付金额的</span>
                        <input type="text" name="ordergetratio" value="0">
                        <span>%计为地推订单收入。</span>
                    </li>
                    <li>
                        <input type="radio" name="accounttype" value="4">
                        <span>前</span>
                        <input type="text" name="topnum" value="0">
                        <span>名有效地推用户：每个有效地推的注册用户</span>
                        <input type="text" name="topregistergetmoney" value="0">
                        <span>元，且该用户的每笔消费按实付金额的</span>
                        <input type="text" name="topordergetratio" value="0">
                        <span>%计为地推订单收入；之后的有效地推用户：每个有效地推的注册用户</span>
                        <input type="text" name="afterregistergetmoney" value="0">
                        <span>元，且该用户的每笔消费按实付金额的</span>
                        <input type="text" name="afterordergetratio" value="0">
                        <span>%计为地推订单收入。</span>
                    </li>
                    <li>
                        <input type="radio" name="accounttype" value="5">
                        <span>每个有效地推的注册用户</span>
                        <input type="text" name="registergetmoney5" value="0">
                        <span>元，且该用户首笔金额满</span>
                        <input type="text" name="rechargeminamount5" value="0">
                        <span>元以上的充值按</span>
                        <input type="text" name="rechargegetmoney5" value="0">
                        <span>元／单计为地推充值收入。</span>
                    </li>
                    <li>
                        <input type="radio" name="accounttype" value="6">
                        <span>每个有效地推的注册用户</span>
                        <input type="text" name="registergetmoney6" value="0">
                        <span>元，且该用户前</span>
                        <input type="text" name="rechargetopnum6" value="0">
                        <span>笔金额满</span>
                        <input type="text" name="rechargeminamount6" value="0">
                        <span>元以上的充值按</span>
                        <input type="text" name="rechargegetmoney6" value="0">
                        <span>元／单计为地推充值收入。</span>
                    </li>
                </ul>
            </li>
        </ul>
        <div class="button">
            <input class="user_setup_preserve" type="button" name="user_setup_preserve" value="保存">
            <input onclick="history.go(-1);" class="user_setup_cancel" type="button" name="user_setup_cancel" value="取消">
        </div>
    </form>
    @else
        <form action="" method="" id="user_setup">
            <ul class="setup_outer">
                <input type="hidden" name="cityid" value="{{$cityid}}" />
                <input type="hidden" name="salesmantype" value="usersalesman">
                <input type="hidden" name="shoptype" value="">
                <input type="hidden" name="edittype" value="{{$edittype}}">
                <input type="hidden" name="salesmansetid" value="{{$id}}">
                <li hidden class="setup_outerli">
                    <span class="front">结算周期：</span>
                    <ul>
                        <li>
                            <input type="radio" name="" value="" checked>
                            <span>每</span>
                            <input type="text" name="accountperiod" value="{{$accountperiod}}">
                            <span>个月结算</span>
                        </li>
                    </ul>
                </li>
                <li class="setup_outerli">
                    <span class="front">地推名称：</span>
                    <input class="setup_name_input" type="text" name="name" value="{{$name}}" placeholder="限20字，请输入地推方案名称" maxlength="20">
                </li>
                <li class="setup_outerli">
                    <span class="front">结算周期：</span>
                    <input class="setup_name_input" type="text" name="accountperioddescription" value="{{$accountperioddescription}}" placeholder="请输入结算周期说明">
                </li>
                <li class="setup_outerli">
                    <span class="front">有效地推定义：</span>
                    <ul>
                    @if($validsalesmanruletype == 1)
                        <li>
                            <input type="radio" name="validsalesmanruletype" value="1" checked>
                            <span>同城新用户下载翻贝网App，首次登录时扫描地推二维码，获取邀请码完成登录即可。首次登录时未获取邀请码，可在2小时内用扫一扫功能扫地推二维码即可。</span>
                        </li>
                        <li hidden>
                            <input type="radio" name="validsalesmanruletype" value="2">
                            <span>新用户登录app且消费</span>
                            <input type="text" name="validorderminnum" value="0">
                            <span>笔，单笔消费金额需达</span>
                            <input type="text" name="validorderminamount" value="0">
                            <span>以上</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="validsalesmanruletype" value="1" checked>
                            <span>同城新用户下载翻贝网App，首次登录时扫描地推二维码，获取邀请码完成登录即可。首次登录时未获取邀请码，可在2小时内用扫一扫功能扫地推二维码即可。</span>
                        </li>
                        <li hidden>
                            <input type="radio" name="validsalesmanruletype" value="2">
                            <span>新用户登录app且消费</span>
                            <input type="text" name="validorderminnum" value="0">
                            <span>笔，单笔消费金额需达</span>
                            <input type="text" name="validorderminamount" value="0">
                            <span>以上</span>
                        </li>
                    @endif
                    </ul>
                </li>
                <li class="setup_outerli">
                    <span class="front">个人地推结算：</span>
                    <ul>
                    @if($accounttype == 1)
                        <li>
                            <input type="radio" name="accounttype" value="1" checked>
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney1" value="{{$registergetmoney}}">
                            <span>元</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="1">
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney1" value="0">
                            <span>元</span>
                        </li>
                    @endif

                    @if($accounttype == 2)
                        <li>
                            <input type="radio" name="accounttype" value="2" checked>
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney2" value="{{$registergetmoney}}">
                            <span>元，且该用户的每笔消费实付金额满</span>
                            <input type="text" name="accountorderminamount" value="{{$accountorderminamount}}">
                            <span>以上的订单按</span>
                            <input type="text" name="ordergetmoney" value="{{$ordergetmoney}}">
                            <span>元／单计为地推订单收入</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="2">
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney2" value="0">
                            <span>元，且该用户的每笔消费实付金额满</span>
                            <input type="text" name="accountorderminamount" value="0">
                            <span>以上的订单按</span>
                            <input type="text" name="ordergetmoney" value="0">
                            <span>元／单计为地推订单收入</span>
                        </li>
                    @endif

                    @if($accounttype == 3)
                        <li>
                            <input type="radio" name="accounttype" value="3" checked>
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney3" value="{{$registergetmoney}}">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="ordergetratio" value="{{$ordergetratio}}">
                            <span>%计为地推订单收入。</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="3">
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney3" value="0">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="ordergetratio" value="0">
                            <span>%计为地推订单收入。</span>
                        </li>
                    @endif

                    @if($accounttype == 4)
                        <li>
                            <input type="radio" name="accounttype" value="4" checked>
                            <span>前</span>
                            <input type="text" name="topnum" value="{{$topnum}}">
                            <span>名有效地推用户：每个有效地推的注册用户</span>
                            <input type="text" name="topregistergetmoney" value="{{$topregistergetmoney}}">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="topordergetratio" value="{{$topordergetratio}}">
                            <span>%计为地推订单收入；之后的有效地推用户：每个有效地推的注册用户</span>
                            <input type="text" name="afterregistergetmoney" value="{{$afterregistergetmoney}}">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="afterordergetratio" value="{{$afterordergetratio}}">
                            <span>%计为地推订单收入。</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="4">
                            <span>前</span>
                            <input type="text" name="topnum" value="0">
                            <span>名有效地推用户：每个有效地推的注册用户</span>
                            <input type="text" name="topregistergetmoney" value="0">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="topordergetratio" value="0">
                            <span>%计为地推订单收入；之后的有效地推用户：每个有效地推的注册用户</span>
                            <input type="text" name="afterregistergetmoney" value="0">
                            <span>元，且该用户的每笔消费按实付金额的</span>
                            <input type="text" name="afterordergetratio" value="0">
                            <span>%计为地推订单收入。</span>
                        </li>
                    @endif

                    @if($accounttype == 5)
                        <li>
                            <input type="radio" name="accounttype" value="5" checked>
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney5" value="{{$registergetmoney}}">
                            <span>元，且该用户首笔金额满</span>
                            <input type="text" name="rechargeminamount5" value="{{$rechargeminamount}}">
                            <span>元以上的充值按</span>
                            <input type="text" name="rechargegetmoney5" value="{{$rechargegetmoney}}">
                            <span>元／单计为地推充值收入。</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="5">
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney5" value="0">
                            <span>元，且该用户首笔金额满</span>
                            <input type="text" name="rechargeminamount5" value="0">
                            <span>元以上的充值按</span>
                            <input type="text" name="rechargegetmoney5" value="0">
                            <span>元／单计为地推充值收入。</span>
                        </li>
                    @endif

                    @if($accounttype == 6)
                        <li>
                            <input type="radio" name="accounttype" value="6" checked>
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney6" value="{{$registergetmoney}}">
                            <span>元，且该用户前</span>
                            <input type="text" name="rechargetopnum6" value="{{$rechargetopnum}}">
                            <span>笔金额满</span>
                            <input type="text" name="rechargeminamount6" value="{{$rechargeminamount}}">
                            <span>元以上的充值按</span>
                            <input type="text" name="rechargegetmoney6" value="{{$rechargegetmoney}}">
                            <span>元／单计为地推充值收入。</span>
                        </li>
                    @else
                        <li>
                            <input type="radio" name="accounttype" value="6">
                            <span>每个有效地推的注册用户</span>
                            <input type="text" name="registergetmoney6" value="0">
                            <span>元，且该用户前</span>
                            <input type="text" name="rechargetopnum6" value="0">
                            <span>笔金额满</span>
                            <input type="text" name="rechargeminamount6" value="0">
                            <span>元以上的充值按</span>
                            <input type="text" name="rechargegetmoney6" value="0">
                            <span>元／单计为地推充值收入。</span>
                        </li>
                    @endif
                    </ul>
                </li>
            </ul>
            <div class="button">
                <input class="user_setup_preserve" type="button" name="user_setup_preserve" value="保存">
                <input onclick="history.go(-1);" class="user_setup_cancel" type="button" name="user_setup_cancel" value="取消">
            </div>
        </form>
    @endif
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var city_id = '{{$cityid}}';
        var edit_type = '{{$edittype}}';
        var salesman_set_id = '{{$salesmansetid}}';
    	$("input[name='user_setup_preserve']").click(function(){
    		$.ajax({
    			url:'/console/salesmanset/update',
    			type:'post',
    			data:$("#user_setup").serialize(),
    			dataType: 'json',
    			success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        if(edit_type == 'add') {
                            window.location.href = '/console/salesman/setup?cityid='+city_id;
                        } else {
                            window.location.href = '/console/salesmanset/user/details?cityid='+city_id+'&salesmansetid='+salesman_set_id;
                        }
                    } else {
                        alert(data.message);return;
                    }
    			}
    		})
    	})
    </script>
@endsection